local config = {
    difftest = false,
    itrace = false,
    clint = false,
    display = true,
    keyboard = true,
}

add_rules("mode.debug", "mode.release", "mode.check")

target("zemu")
    set_languages("cxx17")
    set_kind("binary")
    add_includedirs("include", "/usr/lib/llvm-14/include")
    add_files("src/*/*.cpp")
    add_files("src/*.cpp")
    add_defines("CONFIG_ISA64")
    if config.difftest  then add_defines("CONFIG_DIFFTEST") end
    if config.itrace    then add_defines("CONFIG_ITRACE") end
    if config.clint     then add_defines("CONFIG_CLINT") end
    if config.display   then add_defines("CONFIG_DISPLAY") end
    if config.keyboard  then add_defines("CONFIG_KEYBOARD") end
    add_links("readline", "SDL2")
    set_runargs("--ref=/home/zhengqc/Project/zemu/spike-diff/build/spike-ref-so", 
                "--img=/home/zhengqc/Project/pal-riscv64.bin",
                "--log=/home/zhengqc/Project/zemu/build/log", "-b")
    -- 编译之后执行
    after_build(function (target)
        os.exec("make build")
    end)
    -- 运行之前执行
    before_run(function (target)
        os.exec("make run")
    end)
